<?php 
if(!defined('IN_SONG')) exit('No direct script access allowed');
/**
 * Class Url
 * 
 * @package         Kernel
 * @subpackage      Url
 * @version         0.1
 * @copyright       Song (c) 2011
 */  
class Url
{
    function __construct()
    {
        
    }
    
    /**
    * Build Url
    * 
    * @param Array $params
    * @param String $url 
    * @return String
    * @access Public
    */
    public function buildUrl($params = false, $url = null) {
        $strUrl = '';
        if($url != null) {
            $strUrl .= 'controller='. $url;
        }
        if($params) {
            $strUrl .= http_build_query($params);
        }
        return URL.DS.'?'.$strUrl;
    }
    
    /**
    * Redirect
    * 
    * @param Array $params
    * @param String $url 
    * @access Public
    */
    public function redirect($params = false, $url = null) {  
        header('Location:'. Url::buildUrl($params, $url));
        exit();
    }
    
    /**
    * Redirect Url
    * 
    * @param Array $params
    * @param String $url 
    * @access Public
    */
    public function redirectUrl($url = '') {
        header('Location:'. $url);
        exit();
    }
}
?>
